package com.kma.summer2012.server;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.kma.summer2012.client.ExceptionHandling.CrumbsRPCServiceException;
import com.kma.summer2012.client.services.viewMap.CrumbsViewMapService;
import com.kma.summer2012.facade.MapViewFacade;
import com.kma.summer2012.factory.SpringBeansFactory;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Created by IntelliJ IDEA.
 * User: HP
 * Date: 09.02.13
 * Time: 20:08
 * To change this template use File | Settings | File Templates.
 */
public class CrumbsViewMapServiceImpl extends RemoteServiceServlet implements CrumbsViewMapService {

    public Map<String, List<Integer>> getViewMap(Date date) throws CrumbsRPCServiceException {
        MapViewFacade facade = SpringBeansFactory.getInstance().getBeanByClass(MapViewFacade.class);
        try {
            return facade.sendMap(date);
        } catch (Exception e) {
            System.out.println(e);
            throw new CrumbsRPCServiceException("Getting the map of requests failed.", e);
        }
    }

    @Override
    public Map<Integer, String> getRequestInfoMap(List<Integer> requestIdList) throws CrumbsRPCServiceException {
        MapViewFacade facade = SpringBeansFactory.getInstance().getBeanByClass(MapViewFacade.class);
        try {
            return facade.getRequestInfoMap(requestIdList);
        } catch (Exception e) {
            throw new CrumbsRPCServiceException("Getting request Info failed.", e);
        }

    }

}
